// Copyright 2022 jeff.li. and/or its affiliates.

#pragma once

#include <iconv.h>
#include <cstdarg>
#include <cstring>
#include <locale>
#include <stdexcept>

namespace tbir::runtime {

    inline void StringPrintf(String *str, const char *fmt, ...) {
        if (str) {
            char msg[40960] = {0};
            va_list args;
            va_start(args, fmt);
            vsnprintf(msg, sizeof(msg), fmt, args);
            va_end(args);
            str->clear();
            str->assign(msg);
        }
    }

}  // namespace tbir::runtime
